# Maintainer: nixfloyd <nixfloyd@gmail.com>
pkgname="prometheus-snmp-exporter"
_pkgname="snmp_exporter"
pkgver="0.16.1"
pkgrel=1
pkgdesc="Description"
url="https://github.com/prometheus/snmp_exporter"
arch="all"
license="Apache-2.0"
makedepends="go net-snmp-dev"
install="$pkgname.pre-install"
subpackages="$pkgname-openrc"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/prometheus/snmp_exporter/archive/v$pkgver.tar.gz
	prometheus-snmp-exporter.initd
	prometheus-snmp-exporter.confd
	"
builddir="$srcdir/$_pkgname-$pkgver"


build() {
	go build
	cd generator
	go build
	cd ..
}

check() {
	go test
}

package() {
	# Replace with proper package command(s)
	install -Dm755 snmp_exporter \
		"$pkgdir"/usr/bin/prometheus-snmp-exporter
	install -Dm755 generator/generator \
		"$pkgdir"/usr/bin/prometheus-snmp-generator
	install -Dm644 snmp.yml \
		"$pkgdir"/etc/prometheus/snmp.yml
	install -Dm644 -t "$pkgdir"/usr/share/doc/prometheus-snmp-exporter/ \
		README.md
	install -Dm644 -t "$pkgdir"/usr/share/doc/prometheus-snmp-exporter/examples/ \
		generator/generator.yml
	install -Dm644 -t "$pkgdir"/usr/share/doc/prometheus-snmp-exporter/generator/ \
		generator/README.md
	install -m755 -D "$srcdir"/$pkgname.initd \
		"$pkgdir"/etc/init.d/$pkgname
	install -m644 -D "$srcdir"/$pkgname.confd \
		"$pkgdir"/etc/conf.d/$pkgname
}

sha512sums="ca82464e66c5ac44b46b790582508066e369bcdc1ec9fd06e6576762a8d7afd41bad279717b50f43e3eb7dad156e820432357e52cbbe17e2d87f1621b51e0df5  prometheus-snmp-exporter-0.16.1.tar.gz
42fadcab29b0bac956dd547ca70bb0d3b92b151ba739b5fb94519157ef54f180e13e50a22cb11c701657631bc1c48f3bf5448459ec24bca98fee4f735b07397c  prometheus-snmp-exporter.initd
489cb298e215bd9647aa5293d456106eb26a73f5fbd9d42fab68de26d273ebb612dba01ba113ce58521b543a2f82a10ad86dc35056ef8d0438b39e77be61f67e  prometheus-snmp-exporter.confd"
